<?php

$get_data = $_SERVER["QUERY_STRING"];
$post_data = file_get_contents("php://input");


//$url = "http://$host_ip/cgi-bin/appstage/myapp_manage_taskinfo";
$url = "http://shop.guanmai.cn/wechat?signature=b25301c697ed9f1e75eba053ae8d6f2a1bb529ff&timestamp=1431356232&nonce=1193463614";

//echo send_post($url, $param);
$header = array(
    'Content-Type: text/xml',
);
//echo curl_post($url, $param, $header);
echo send_post($url, $post_data);

function curl_post($url, $post_data, $host=array())
{       
    $data = is_array($data) ? http_build_query($data) : $data;
    $ch = curl_init();
    $res= curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);  
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HEADER, 0); 
    curl_setopt($ch, CURLOPT_POST, 1);  
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);  
    curl_setopt($ch, CURLOPT_HTTPHEADER, $host);         
    $result = curl_exec($ch);
    $err = curl_error($ch); 
    curl_close($ch);

    if ($result == NULL)
    {
        return false;
    }   
    return $result;
}


function send_post($url, $post_data) {   
      $postdata = $post_data;   
      $options = array(   
              'http' => array(   
              'method' => 'POST',   
              'header' => 'Content-type:text/xml',   
              'content' => $postdata,   
              'timeout' => 15 * 60    
                           )   
      );   
      $context = stream_context_create($options);   
      $result = file_get_contents($url, false, $context);   
      return $result;   
}   

?>